package com.cskaoyan.service.wx;

import com.cskaoyan.bean.index.OrderBean;
import com.cskaoyan.bean.po.MarketOrder;
import com.cskaoyan.bean.po.MarketOrderExample;
import com.cskaoyan.bean.wx.user.UserIndexData;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ClassName: WxUserIndexServiceImpl
 * Description:
 * date: 2022/6/9 15:33
 *
 * @author bruce
 * @since JDK 8
 */
@Service
public class WxUserIndexServiceImpl implements WxUserIndexService {

   @Autowired
   MarketOrderMapper marketOrderMapper;

    @Override
    public UserIndexData query(Integer userId) {
        Integer unpaid = marketOrderMapper.countStatus(101,userId);
        Integer unship = marketOrderMapper.countStatus(201,userId);
        Integer unrecv = marketOrderMapper.countStatus(301,userId);
        Integer uncomment = marketOrderMapper.countByComments(userId);
        if (uncomment == null) {
            uncomment = 0;
        }
        OrderBean orderBean = new OrderBean(unrecv,uncomment,unpaid,unship);
        return UserIndexData.data(orderBean);
    }
}
